<template>
	<view class="">
		<view class="header">
			<view class="my_info flex algin">
				<view class="avator">
					<image :src="user.avatar" mode="aspectFill"></image>
				</view>
				<view class="width70">
					<view class="flex justify align">
						<view class="user_name">
							{{user.encoded}}
						</view>
						<view class="user_tag">
							{{user.label_name}}
						</view>
					</view>
					<view class="ident flex align" @tap="toIdent">
						
						<image v-if="user.is_verify == 1" src="../../static/icon/icon/my/renzheng2.png" mode="aspectFill"></image>
						<image v-else src="../../static/icon/icon/my/renzheng.png" mode="aspectFill"></image>
						<text class="successIdent" v-if="user.is_verify == 1">已认证</text>
						<text v-if="user.is_verify == 0 &&  user.verify_status != 2">未认证</text>
						<text class="noIdent" v-if="user.verify_status == 2">认证失败</text>
						<image v-if="user.is_verify != 1" src="../../static/icon/right2.png" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<view class="setting flex justify align">
				<view class="setting_item flex justify align" v-if="user.group_id== 2" @tap="toProduct">
					<view class="">
						<view class="setting_item_title">
							发布项目
						</view>
						<view class="">
							发布项目
						</view>
					</view>
					<image class="setting_icon" src="../../static/icon/icon/my/fabu.png" mode="aspectFill"></image>
				</view>
				<view class="setting_item flex justify align" v-if="user.group_id== 2" @tap="toprojectManagement(1)">
					<view class="">
						<view class="setting_item_title">
							项目管理
						</view>
						<view class="">
							项目管理
						</view>
					</view>
					<image class="setting_icon" src="../../static/icon/icon/my/guanli.png" mode="aspectFill"></image>
				</view>
			</view>
			<view class="setting flex justify align">
				<view class="setting_item flex justify align" v-if="user.group_id== 3" @tap="toBusiness">
					<view class="">
						<view class="setting_item_title">
							发布名片
						</view>
						<view class="">
							发布企业名片
						</view>
					</view>
					<image class="setting_icon" src="../../static/icon/icon/my/fabu.png" mode="aspectFill"></image>
				</view>
				<view class="setting_item flex justify align" v-if="user.group_id== 3" @tap="toprojectManagement(2)">
					<view class="">
						<view class="setting_item_title">
							名片管理
						</view>
						<view class="">
							企业名片管理
						</view>
					</view>
					<image class="setting_icon" src="../../static/icon/icon/my/guanli.png" mode="aspectFill"></image>
				</view>
			</view>
		</view>
		<view class="my_server">
			<view class="server_title">
				我的服务
			</view>
			<view class="flex align">
				<view class="server_item" @tap="toUrl(0)">
					<image src="../../static/icon/icon/my/guanzhu.png" mode="aspectFill"></image>
					<view class="">
						我的关注
					</view>
				</view>
				<view class="server_item" @tap="toUrl(1)">
					<image src="../../static/icon/icon/my/shoucang.png" mode="aspectFill"></image>
					<view class="">
						我的收藏
					</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="item flex justify align" @tap="toCall()">
				<view class="flex align">
					<image class="item_icon" src="../../static/icon/icon/my/kefu.png" mode="aspectFill"></image>
					<text>联系客服</text>
				</view>
				<image class="right" src="../../static/icon/right.png" mode="aspectFill"></image>
			</view>
			<view class="item flex justify align" @tap="tofeedback">
				<view class="flex align">
					<image class="item_icon" src="../../static/icon/icon/my/yijian.png" mode="aspectFill"></image>
					<text>意见反馈</text>
				</view>
				<image class="right" src="../../static/icon/right.png" mode="aspectFill"></image>
			</view>
			<view class="item flex justify align" @tap="toaboutUs">
				<view class="flex align">
					<image class="item_icon" src="../../static/icon/icon/my/mys.png" mode="aspectFill"></image>
					<text>关于我们</text>
				</view>
				<image class="right" src="../../static/icon/right.png" mode="aspectFill"></image>
			</view>
		</view>
		<view-tabbar selected="2"></view-tabbar>
	</view>
</template>

<script>
	const app = getApp()
	export default {
		data() {
			return {
				user: '',
				newsList: [],
				info: {}
			}
		},
		onLoad() {
			const  _this = this
			if (app.globalData.user) {
				_this.user = app.globalData.user
			} else {
				
				app.flagLogin().then(() => {
					console.log('回调2---------------', app.globalData.user)
					_this.user = app.globalData.user
				})
			}
		},
		onShow() {
			this.getNewsList()
			app.getData('addons/shopro/category/gz', {}).then(res => {
				console.log('1', res)
			})
			app.getUser().then(data => {
				console.log('用户登录信息-->', data)
				app.globalData.user = data.data.data
				this.user = data.data.data
			})
			app.getData('api/config_basic/index',{name:'about_us'}).then(res=>{
				console.log(res)
				this.info = res.data.data
			})
		},
		methods: {
			// 获取消息列表
			getNewsList() {
				app.getData('/addons/shopro/message', {}).then(res => {
					console.log('====', res)
					this.newsList = res.data.data
				})
			},
			// 我的收藏 
			toUrl(ind) {
				uni.navigateTo({
					url: '/pages/myFollow/myFollow?type=' + ind
				})
			},
			toCall() {
				uni.makePhoneCall({
					phoneNumber: this.info.phone //仅为示例
				});
			},
			tofeedback() {
				uni.navigateTo({
					url: '/pages/feedback/feedback'
				})
			},
			toaboutUs() {
				uni.navigateTo({
					url: '/pages/aboutUs/aboutUs'
				})
			},
			// 去认证
			toIdent() {
				if(this.user.is_verify != 1){
					uni.navigateTo({
						url: '/pages/identification/identification'
					})
				}
				
			},
			// 发布项目
			toProduct() {
				uni.navigateTo({
					url: '/pages/publishProject/publishProject'
				})
			},
			// 项目管理
			toprojectManagement(index) {
				if(index == 2){
					uni.navigateTo({
						url: '/pages/businessCard/businessCard?isEdit=1&id='+this.user.user_id
					})
				}else{
					uni.navigateTo({
						url: '/pages/projectManagement/projectManagement'
					})
				}
				
			},

			// 发布名片
			toBusiness() {
				if(this.user.visiting_card_id != 0){
					uni.showToast({
						title:'您已发布名片，如仍需发布请联系客服！',
						icon:'none'
					})
					return
				}
				uni.navigateTo({
					url: '/pages/businessCard/businessCard'
				})
			},
			// 获取用户信息
		}
	}
</script>

<style>
	page {
		background: #F7F7F7;
	}

	.header {
		background: #fff;
		margin: 30rpx;
		padding: 24rpx;
		border-radius: 10rpx;
	}

	.my_info {
		border-radius: 10rpx;
		margin-bottom: 40rpx;
	}

	.avator image {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		margin-right: 28rpx;
	}

	.width70 {
		width: 70%;
	}

	.user_name {
		font-weight: 600;
		font-size: 34rpx;
		margin-bottom: 20rpx;
		margin-top: 10rpx;
	}

	.user_tag {
		color: #fff;
		padding: 4rpx 8rpx;
		border-radius: 4rpx;
		background-color: var(--base);
	}

	.ident {
		color: #333;

	}

	.ident image {
		width: 24rpx;
		height: 24rpx;
	}

	.noIdent {
		color: red;
	}

	.successIdent {
		color: var(--base);
	}

	.setting image {
		width: 74rpx;
		height: 74rpx;
	}

	.setting_item {
		width: 41%;
		color: #999;
		font-size: 24rpx;
		padding: 20rpx;
		box-shadow: 0 0 10rpx #eee;
	}

	.setting_item_title {
		color: #000;
		font-size: 28rpx;
		margin-bottom: 10rpx;
	}

	.my_server,
	.list {
		margin: 30rpx;
		background: #fff;
		border-radius: 10rpx;
	}

	.my_server {
		padding: 20rpx;
	}

	.my_server image {
		width: 46rpx;
		height: 46rpx;
	}

	.server_title {
		font-size: 30rpx;
		margin-bottom: 30rpx;
	}

	.server_item {
		width: 130rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.server_item image {
		margin-bottom: 20rpx;
	}

	.list image {
		width: 36rpx;
		height: 36rpx;
	}

	.list .item {
		height: 90rpx;
		padding: 0 20rpx;
	}

	.item_icon {
		margin-right: 20rpx;
	}

	.right {
		width: 24rpx;
		height: 24rpx;
	}
</style>
